package main

import (
	"crypto/tls"
	"gdei_healthy_colly/config"
	"gdei_healthy_colly/log"
	"go.uber.org/zap"
	"math/rand"
	"net/http"
	"time"
	_ "time/tzdata"
)

func init() {
	var err error
	defer func() {
		if err != nil {
			log.Logger.Panic("[配置加载]", zap.Error(err))
		}
	}()

	if err = config.LoadConfig(); err != nil {
		log.Logger.Fatal("[初始化失败]", zap.Error(err))
	}
	if err = loadCmd(); err != nil {
		return
	}

	// FIX x509: certificate signed by unknown authority
	http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

	// FIX TIMEZONE
	time.Local, err = time.LoadLocation("Asia/Shanghai")

	rand.Seed(time.Now().UnixNano())
}

func main() {
	if err := rootCMd.Execute(); err != nil {
		log.Logger.Debug("[系统]", zap.Error(err))
	}
}
